<template>
  <div class="register-page">
    <van-nav-bar
      title="房屋管理"
      class="manageTop"
      left-arrow
      @click-left="regFn"
    />
    <div class="kong"></div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <CollectPage
        v-for="item in list"
        :key="item.id"
        :item="item"
      ></CollectPage>
    </van-list>
  </div>
</template>

<script>
import CollectPage from "@/components/CollectPage.vue";
import { manageHouse } from "@/api/user";
export default {
  components: {
    CollectPage,
  },
  data() {
    return {
      list: [],
      finished: false,
      loading: false,
    };
  },
  methods: {
    async onLoad() {
      const res = await manageHouse();
      console.log(res);
      if (res.body) {
        this.list = res.body;
      } else {
        this.$router.push("/login");
      }
    },
    regFn() {
      this.$router.back();
    },
  },
};
</script>

<style scoped>
.manageTop {
  position: fixed;
  width: 100%;
}
.kong {
  width: 100%;
  height: 50px;
}
</style>
